{	Problem: http://codeforces.ru/problemset/problem/94/A
	Verdict: Accepted
}
var
    s,cs:string;
    t:array[0..10] of string;
    i:longint;

begin
readln(s);
for i:=0 to 9 do
    readln(t[i]);
while length(s)>0 do begin
    cs:=copy(s,1,10);
    for i:=0 to 9 do
        if cs=t[i] then begin
            write(i);
            break;
        end;
    delete(S,1,10);            
end;
end.